//
//  AppWizardView.m
//  suRead
//
//  Created by 李 诗洋 on 15/11/19.
//  Copyright © 2015年 bao. All rights reserved.
//

#import "AppWizardView.h"
#import "UserDefaultsUtils.h"

#import "UIControl+Blocks.h"

#define kDeviceWidth [UIScreen mainScreen].bounds.size.width
#define KDeviceHeight [UIScreen mainScreen].bounds.size.height

@implementation AppWizardView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initUI];
    }
    return self;
}
-(void)initUI
{
    __weak typeof(self) weak_self = self;

    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, KDeviceHeight)];
    [self.scrollView setContentSize:CGSizeMake(kDeviceWidth * 1, KDeviceHeight)];
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.scrollView setPagingEnabled:YES];  //视图整页显示
    [self.scrollView setBounces:NO]; //避免弹跳效果,避免把根视图露出来
    self.scrollView.scrollEnabled = NO;
    [self addSubview:self.scrollView];
    
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, KDeviceHeight)];
    [imageview setImage:[UIImage imageNamed:@"kaiji1"]];
    [self.scrollView addSubview:imageview];

//    self.button = [[UIButton alloc] initWithFrame:CGRectMake(kDeviceWidth - 15 - 42, KDeviceHeight-77 + (77 / 2 - 20 / 2), 42, 20)];
//    self.button.backgroundColor = [UIColor darkGrayColor];
//    [self.button setTitle:@"跳过" forState:UIControlStateNormal];
//    [self addSubview:self.button];
//    [self.button addActionForControlEvents:UIControlEventTouchUpInside usingBlock:^(UIControl *sender, UIEvent *event) {
//        
//        [UserDefaultsUtils saveBoolValue:YES withKey:@"firstLaunch"];
//        [weak_self removeFromSuperview];
//    }];

    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [UserDefaultsUtils saveBoolValue:YES withKey:@"firstLaunch"];
        UIApplication *application=[UIApplication sharedApplication];
        [application setStatusBarHidden:NO];
        [weak_self removeFromSuperview];
    });
}

@end
